package com.saturn.action.sldb.discussion;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.saturn.app.web.IAction;
import com.saturn.app.web.IView;
import com.saturn.app.web.view.JspView;
import com.saturn.sldb.Discussion;

public class QueryDiscussionAction implements IAction{
	@Override
	public IView execute(HttpServletRequest request,
			HttpServletResponse response) {
		String id = request.getParameter("id");
		String view = request.getParameter("view");
		String type= request.getParameter("type");
		
		Discussion vo = Discussion.get(id);
		request.setAttribute("discussion", vo);
		if("2".equals(type)){
				request.setAttribute("discussion", vo);
				return new JspView("/app/sldb/discussion/apply/editByAuto.jsp");
		}else if("3".equals(type)){
			request.setAttribute("discussion", vo);
			return new JspView("/app/sldb/discussion/apply/edit.jsp");
		}else{
			if("ok".equals(view)){
				return new JspView("/app/sldb/discussion/apply/view.jsp");
			} else{
				request.setAttribute("discussion", vo);
				return new JspView("/app/sldb/discussion/apply/edit.jsp");
			}
		}
	}
	@Override
	public String requestMapping() {
		return "/app/sldb/discussion/query.action";
	}
}
